package cn.sdormitory.smartdor.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;

import java.util.Date;
import java.util.Objects;

/**
 * @className: StudentTrajectory
 * @author: Alex
 * @date: 2024/9/25
 **/
@Data
@TableName("t_student_trajectory")
public class StudentTrajectory{
	
	private Long id;
	
	private Long studentId;
	
	@TableField(exist = false)
	private String studentName;
	
	private String cardName;
	
	@TableField(exist = false)
	private String className;
	
	private String deviceAddr;
	
	private String faceTime;
	
	private String type;
	
	private String snapFtpUrl;
	
	private String studentType;
	
	private Date createTime;
	
	@TableField(exist = false)
	private String dormitoryInfo;
	
	@TableField(exist = false)
	private Integer dormitoryStatus;
	
	private String createBy;
	
	public void initDormitoryStatus(){
		if(dormitoryInfo == null || dormitoryInfo.equals("走读")){
			return;
		}
		if(!Objects.equals(type, "3") || deviceAddr == null || deviceAddr.length() < 3 || !deviceAddr.endsWith("楼")){
			dormitoryStatus = 0;
		}
		char c = deviceAddr.charAt(deviceAddr.length() - 2);
		if(c >= '1' && c <= '9'){
			String str = deviceAddr.substring(0, deviceAddr.length() - 2)+"-"+c;
			dormitoryStatus = dormitoryInfo.startsWith(str) ? 1 : 0;
		}
	}
	
}
